package com.zhsm.fuxi.mvp.ui.dialog

import android.content.Context
import com.zhsm.fuxi.R
import com.zhsm.fuxi.base.BaseDialog
import kotlinx.android.synthetic.main.dialog_back_error.*
import org.jetbrains.anko.sdk25.coroutines.onClick


/**
 * Created by GuZhC on 2018/11/13.
 * describe:
 */
class BackCarErrorDialog(context: Context) : BaseDialog(context) {

    override fun getLayoutId(): Int {
        return R.layout.dialog_back_error
    }

    override fun getGravity(): Int {
        return BaseDialog.GRAVITY_CENTER
    }

    override fun isCanceledOnTouchOutside(): Boolean {
        return true
    }

    override fun initView() {
        super.initView()
        backCarAgain.onClick {
//            mOnClickBtn?.backAgain()
            dismiss()
        }
        dialogRoot.onClick { dismiss() }
    }


    fun setErrorInfo(info: List<String>) {
        val sb = StringBuilder()
        info.forEach {
            if (!it.isNullOrBlank()) {
                sb.append(it)
                sb.append("\n")
            }
        }
        backCarErrorInfo.text = sb.toString()
    }





    interface onClickBtn {

        //下一步
        fun backAgain()
    }

    internal var mOnClickBtn: onClickBtn? = null

    fun setBackAgain(mOnClickBackAgain: onClickBtn?) {
        this.mOnClickBtn = mOnClickBackAgain
    }

}